import Vue from 'vue'
import Vuex from 'vuex'
import {getPositionList} from '../api/index'
import { Indicator,Toast } from 'mint-ui'
import 'mint-ui/lib/style.css'
import BScroll from '@better-scroll/core'
import Pullup from '@better-scroll/pull-up'
import axios from 'axios'
BScroll.use(Pullup)

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    // 当前默认城市
    city:"北京",
    // 要搜索的信息
    search:'',
    // 职位列表
    positionlist:[],
  },
  mutations: {
    SET_CITY(state,options){
      state.city = options;
    },
    SET_SEARCHLIST(state,options){
      state.search = options
    },
    initList(state,list){
      state.positionlist = list;  
    },
    // getNewList(state,search){
      
    // }
  },
  actions: {
    // async getList(context){
    //   let rs = await getPositionList();
      // console.log("aaa",rs.data)
      // console.log("过滤-----"+this.state.search)
      // if(this.state.search||this.state){
      //   console.log("过滤"+this.state.search)
      //   return rs.data.filter(item=>item.position.indexOf(this.state.search)!==-1)  
      // }
      // console.log("getList",rs.data);
    //   context.commit("initList",rs.data);
    // },
    // getNewList(context,search){
    //   state.positionlist = state.newslist.filter(item=> {
    //     return new RegExp(options).test(item.position)
    //   })
    // }
  }, 
  getters:{
    // filterList(state){
    //   if(state.search){
    //     console.log("fil",state.search)
    //     state.positionlist = state.positionlist.filter(item=>{
    //       return  state.search==item.position
    //     })
    //     console.log("???",state.positionlist)
    //     return state.positionlist
    //   }
    // }
  },
  modules: {
    
  }
})
